package cn.zhuangcloud.word.object.question;

public class ChoiceQuestion implements IQuestion {

    private int choiceNum;
    private String question;
    private String[] choices;
    private String answer;
    private Boolean isMultipleChoice;
    private String standardAnswer;

    public ChoiceQuestion(int choiceNum, String question, String[] choices, String answer, Boolean isMultipleChoice, String standardAnswer) {
        this.choiceNum = choiceNum;
        this.question = question;
        this.choices = choices;
        this.answer = answer;
        this.isMultipleChoice = isMultipleChoice;
        this.standardAnswer = standardAnswer;
    }

    public ChoiceQuestion(String question, String[] choices, String answer, Boolean isMultipleChoice, String standardAnswer) {
        this.choiceNum = choices.length;
        this.question = question;
        this.choices = choices;
        this.answer = answer;
        this.isMultipleChoice = isMultipleChoice;
        this.standardAnswer = standardAnswer;
    }

    public int getChoiceNum() {
        return choiceNum;
    }

    public void setChoiceNum(int choiceNum) {
        this.choiceNum = choiceNum;
    }

    public String getQuestion() {
        return question;
    }

    public void setQuestion(String question) {
        this.question = question;
    }

    public String[] getChoices() {
        return choices;
    }

    public void setChoices(String[] choices) {
        this.choices = choices;
    }

    public String getAnswer() {
        return answer;
    }

    public void setAnswer(String answer) {
        this.answer = answer;
    }

    public Boolean getMultipleChoice() {
        return isMultipleChoice;
    }

    public void setMultipleChoice(Boolean multipleChoice) {
        isMultipleChoice = multipleChoice;
    }

    public String getStandardAnswer() {
        return standardAnswer;
    }

    public void setStandardAnswer(String standardAnswer) {
        this.standardAnswer = standardAnswer;
    }

    public String getType() {
        return isMultipleChoice ? "MultipleChoice" : "Choice";
    }

    public String getDisplayAnswer() {
        String display = "(" + answer + ")";
        if (answer.equalsIgnoreCase(standardAnswer)) {
            display += "<span class=\"judge\">√</span>";
        } else {
            display += "<span class=\"judge\">×&nbsp;正确答案：" + standardAnswer + "</span>";
        }
        return display;
    }

}
